<!DOCTYPE html>
<html>
<head>
    <title>使用记录</title>
</head>
<body class="layui-layout-body">
    <div class="layui-body">
        <!-- 内容主体区域 -->
        <div class="body_right">
            <h4 class="nav_title">使用记录</h4>
            <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
                <ul class="layui-tab-title">
                    <li lay-id="APPLY">申请记录</li>
                    <li lay-id="APPROVE">授权印章</li>
                    <li lay-id="USED" class="layui-this">使用印章</li>
                    <li lay-id="TAKE">外带印章</li>
                </ul>
                <div class="layui-tab-content" style="height: 100px;">
                    <div class="layui-tab-item layui-show">
				        <form action="/apply/used/list.htm" class="layui-form no_bordertop" method="get">
			                <div class="layui-form-item">
			                    <div class="layui-inline">
			                    		<label class="layui-form-label">使用时间</label>
			                        <div class="layui-input-inline" style="width:100px">
			                            <input type="text" class="layui-input" name="startTime" id="startTime" autocomplete="off" value="<#if query.startTime??>${query.startTime?string('yyyy-MM-dd')}</#if>" placeholder="开始时间">
			                        </div>
			                        <div class="layui-form-mid">-</div>
			                        <div class="layui-input-inline" style="width:100px">
			                            <input type="text" class="layui-input" name="endTime" id="endTime" autocomplete="off" value="<#if query.endTime??>${query.endTime?string('yyyy-MM-dd')}</#if>" placeholder="结束时间">
			                        </div>
			                    </div>
			                    <div class="layui-inline">
                                    <label class="layui-form-label">印章名称</label>
                                     <div class="layui-input-inline" style="width:150px">
                                        <input type="text" class="layui-input" name="sealName" value="${query.sealName}" id="sealName" placeholder="">
                                    </div>
                                </div>
			                    <div class="layui-inline width80">
			                        <div class="layui-input-inline ">
			                            <button class="layui-btn" lay-submit="" lay-filter="demo1" >搜索</button>
			                        </div>
			                    </div>
			                </div>
			            </form>
					    
                        <table class="layui-table mytable" lay-even="" lay-skin="nob">
                            <thead>
	                            <tr>
	                                <th>使用时间</th>
	                                <th>使用印章</th>
	                                <th>使用设备</th>
	                                <th>使用凭证</th>
	                                <th>使用状态</th>
	                                <th>操作</th>
	                            </tr>
                            </thead>
                            <tbody>
                            	<#list pm.datas as item>
	                            <tr>
	                            	<td>${item.usedTime?string("yyyy-MM-dd HH:mm:ss")}</td>
	                                <td>${item.seal.sealName}</td>
	                                <td>${item.devices.devicesCode}</td>
	                                <th>
	                                	<#if item.usedStatus=='WAIT_UPLOAD_CERT'>
		                        			<a href="javascript:;" class="demoMore" lay-data="{devicesId: ${item.devicesId},devicesUsedId:${item.devicesUsedId}}">上传</a>
		                        		<#else>
		                        			<a href="${item.voucherUrl}">下载</a>
		                        		</#if>
	                                </th>
	                                <td>
	                                	<@linkage type="USED_STATUS" key=item.usedStatus>
							        		<span class="${linkage.style}">${linkage.name}</span>
							        	</@linkage>
	                                </td>
	                                <td>
	                                	
	                                	<a href="javascript:javascript:openwinx('查看','/custos/usedInfo.htm?devicesUsedId=${item.devicesUsedId}',800,500);">查看</a>
	                                
	                                </td>
	                            </tr>
	                            </#list>
                            </tbody>
                        </table>
                    </div>
                    
                </div>
            </div>
        </div>
     </div>
<script>
layui.use(['element','laydate','upload'], function(){
	  var $ = layui.jquery,element = layui.element,laydate = layui.laydate,upload=layui.upload; 
	  element.on('tab(docDemoTabBrief)', function(elem){
	  		var id = $(this).attr('lay-id');
	  		if(id == 'APPLY'){
		  		 	location.href='/apply/list.htm';
		  	}
	  		if(id == 'APPROVE'){
	  		 	location.href='/apply/approve/list.htm';
	  		}
	  		
	  		if(id == 'TAKE'){
	  			 location.href='/apply/take/list.htm';
	  		}
	  });
	  
	  laydate.render({
	    elem: '#startTime'
	  });
	  
	  laydate.render({
	    elem: '#endTime',
	    min:$("#startTime").val()
	  });
	  
	  
	  
	  
	  upload.render({
    elem: '.demoMore'
    ,url: '/upload/fileupload.htm?module=cert'
    
    ,done: function(res, index, upload){
      var devicesId = this.devicesId;
      var devicesUsedId = this.devicesUsedId;
      console.log(res);
      if(res.code == 1){
      		
      		var field = {
      			devicesId:devicesId,
      			devicesUsedId:devicesUsedId
      		}
      		field['upfiles[0].upfileId'] = res.data.upfileId;
          	field['upfiles[0].fileUrl'] = res.data.filepath;
      		
      		$.ajax({
      			type:"POST", 
      			url:"/devices/upcert.htm",
      			data:field,
      			success:function(result) {
		      
		      		if(result.code=='1'){
		      			layer.msg("上传成功");
		      			location.reload();
		      		}else{
		      		 	layer.msg(result.msg);
		      		}
		      
		    	 	} 
		    }); 
      	
      
      }
      
    }
  })
	  
	  
	  
});
</script>
</body>
</html>